package com.ymatou.auth.service;

import org.json.JSONException;
import org.json.JSONObject;

import com.ymt.base.YmatouBaseCall;
import com.ymttest.utils.EnvSetup;

/**
*用户凭据更新请求接口Call
*FreeMaker Template自动生成代码
*/
public class UserBillsRequestDtoCall extends YmatouBaseCall{
	private static String opurl ="json/reply/UserBillsRequestDto";
	
	public UserBillsRequestDtoCall() {
		super(EnvSetup.getSystemUrl("api_auth"),opurl,"POST","JSON");
	}
	
	@Override
	public void addDefHeader() {
		client.addHeader("Accept","text/xml,text/javascript,text/html,application/json");
		client.addHeader("Content-Type", "application/json; charset=UTF-8");
	}
	
	/**
	 * 获取是否成功
	 * 
	 * @return Boolean
	 */
	public Boolean getSuccess() {
		Boolean Success = null;
		try {
			JSONObject jo = new JSONObject(getReturnData());
			Success = jo.getBoolean("Success");
		} catch (Exception e) {
			e.printStackTrace();
		}
		return Success;
	}
	
	/**
	 * 获取操作结果
	 * 
	 * @return String
	 */
	public String getResult() {
		String result = null;
		try {
			result = new JSONObject(getReturnData()).get("Result").toString();
		} catch (Exception e) {
			e.printStackTrace();
		}
		return result;
	}
	
	/**
	 * 获取Msg信息
	 * @return
	 */
	public String getMsg(){
		String msg=null;	
		try {
			msg=new JSONObject(getReturnData()).getString("LastErrorMessage");
		} catch (JSONException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return msg;
	}
}